import axios from "axios";
import qs from "qs";
const weiService = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
		"Api-Version": "1.3.0"
	},
	transformRequest: [
		function(data) {
			data = qs.stringify(data);
			return data;
		}
	]
});

const v11Service = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/json",
		"Api-Version": "1.1.0"
	}
});
const bbsservice = axios.create({
	timeout: 5000,
	headers: {
		Accept: "*/*",
		"Content-Type": "application/json",
		"Api-Version": "1.0.0"
	}
});
const v13service = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/json",
		"Api-Version": "1.3.0"
	}
});
const v10Service = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/json",
		"Api-Version": "1.0.0"
	}
});

const v16Service = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/json",
		'Api-Version': '2.0.1',
		'version': '2.0.0'
	}
});
const v15Service = axios.create({
	timeout: 5000,
	headers: {
		"Content-Type": "application/json",
		'Api-Version': '2.0.1',
		'version': '2.0.0'
		}
});
const vH5Service = axios.create({
	timeout: 5000,
	headers: {
		Accept: "*/*",
		"Content-Type": "application/json",
		// "Cache-Control": "no-cach",
		'Api-Version': '1.0.0',
		}
});



export default {

	// 获取院校动态详情
	getSchoolMsg(params, token) {
		return vH5Service({
			method: "get",
			url: `/schoolApi/academy/answerService/moments/${params}`,
			// data: params,
			headers: {"accessToken": token}
		});
	},
	//获取话题详情
	getTopicInfo(params) {
		return bbsservice({
			method: "post",
			url: "/shengxueApi/moments/open/detail/queryTopicInfo",
			data: params
		});
	},
	//获取课程详情
	getLessonDetail(params) {
		return v11Service({
			method: "post",
			url: `/shengxueApi/openapp/share`,
			data: params
		});
	},
	//适配ios接口
	getbbsHeadlines(params) {
		return v13service({
			method: "post",
			url: "/shengxueApi/information/topic/info",
			data: params
		});
	},
	//适配安卓接口
	getbbsAndroidHeadlines(params) {
		return v13service({
			method: "post",
			url: "/shengxueApi/information/topic/info",
			data: params
		});
	},
	
	// 新闻详情页-热门评论分页
	topicCommentPage(params) {
		return v15Service({
			method: "post",
			url: "/shengxueApi/moments/topicCommentPage",
			data: params
		});
	},

	// 新闻详情页-评论
	infoTopicComment(params, token) {
		return v15Service({
			method: "post",
			url: "/shengxueApi/moments/infoTopicComment",
			data: params,
			headers: {"accessToken": token}
		});
	},

	//二次分享
	getSecondShareKey(data) {
		var data2 = {
			url: data["url"]
		};
		return weiService({
			method: "post",
			url: "/api/wechat/getsignature",
			data: data2
		});
	},
	//点赞
	likeTopic(action, topicId) {
		// action (integer, optional): 点赞 1;取消赞 0 ,
		// topicId (integer, optional): 帖子ID
		let data = {
			action: action,
			topicId: topicId
		};
		return v10Service({
			method: "post",
			url: "/shengxueApi/moments/topic/likeTopic",
			data
		});
	},
	//资讯点赞
	likeInformation(data,token){
		return v13service({
			method: "post",
			url: "/shengxueApi/information/topic/operLike",
			data: data,
			headers: {"accessToken": token}
		})
	},
	// 实时注册的用户数据
	addUser(token){
		return v15Service({
			method: "get",
			url: "/manager/report/actualUsers",
			headers: {"accessToken": token}
		})
	},
	// 查询全国区域统计数据
	chinaData(token){
		return v15Service({
			method: "get",
			url: "/manager/report/areaStatistic",
			headers: {"accessToken": token}
		})
	},
	// 查询区域和学校排行榜
	rankingData(data, token){
		return v15Service({
			method: "post",
			url: "/manager/report/areaSchoolRanking",
			data: data,
			headers: {"accessToken": token}
		})
	},
	// 查询用户总数和机构总数
	userAgencyCount(token){
		return v15Service({
			method: "get",
			url: "/manager/report/userAgencyCount",
			headers: {"accessToken": token}
		})
	},
	// 查询问答详情
	getQuestionDetail(data, token){
		return v16Service({
			method: "post",
			url: "/shengxueApi/professor/getQuestionDetail",
			data: data,
			headers: {"accessToken": token}
		})
	},
	
	// 获取专家个人详情
	specialistDetail(data, token){
		return v16Service({
			method: "post",
			url: "/shengxueApi/agencyUser/Info",
			data: data,
			headers: {"accessToken": token}
		})
	},
	// 查询专家首页详情
	specialistQuestionList(data, token){
		return v16Service({
			method: "post",
			url: "/shengxueApi/professor/professorQusAndAnsPage",
			data: data,
			headers: {"accessToken": token}
		})
	},
	// 查询专家首页详情
	specialistPageList(data, token){
		return v16Service({
			method: "post",
			url: "/shengxueApi/expertInfo/pageList",
			data: data,
			headers: {"accessToken": token}
		})
	},
	// 获取商品详情---分享页  
	getCourseDetail(params) {
		return v16Service({
			method: "post",
			url: `/shengxueApi/openapp/info`,
			data: params,
		});
	},
	// 专题详情---分享页  
	getSubjectDetail(params) {
		return v16Service({
			method: "post",
			url: `/shengxueApi/openapp/getCommodityTopicDetail`,
			data: params,
		});
	},
	
};
